package com.mr.example2.topn;

import java.io.IOException;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

/*
 * 对总流量降序排序
 * 13470253144	180	180	360
 */

public class FlowBeanExample2Mapper extends Mapper<LongWritable, Text, LongWritable, Text>{

	@Override
	protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, LongWritable, Text>.Context context)
			throws IOException, InterruptedException {


		String[] words = value.toString().split("\t");

		// 写出key-value
		// key：总流量
		// value：手机号+上行流量+下行流量
		context.write(new LongWritable(Long.parseLong(words[3])), new Text(words[0] + '\t' + words[1] + '\t' + words[2] + '\t' ));

	}


}
